#include <boost/algorithm/string.hpp>
#include <strings.h>
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;
using namespace boost;

//URL related:

static int caculateDomainForURL(string URL){
	vector<string> strs;
	vector<string> elements;
	split(strs, URL, is_any_of("/") );
	//cout << "* size of the vector: " << strs.size() << endl;
	//for (size_t i = 0; i < strs.size(); i++)
	//    cout << i << " "<< strs[i] << endl;


	split(elements, strs[2], is_any_of(".") );
	//cout << "* size of the vector: " << elements.size() << endl;
	//for (size_t i = 0; i < elements.size(); i++)
	//    cout << i << " "<< elements[i] << endl;


	//cout << "	Feature:URL_Domain:" << elements[2] << endl;
	return 0;
}

static int caculateNumberOfNestingLevelsForURL(string URL){
	int numberOfLevels;
	vector<string> strs;
	split(strs, URL, is_any_of("/") );
	//cout << "* size of the vector: " << strs.size() << endl;
	//for (size_t i = 0; i < strs.size(); i++)
	//    cout << i << " "<< strs[i] << endl;
	numberOfLevels = strs.size() -3;
	//cout << "	Feature:URL_Number_of_Nesting_Levels:" << numberOfLevels << endl;
	return 0;
}

static int caculateLengthForURL(string URL){
	//cout << "	Feature:URL_Length_of_URL:" << URL.length() << endl;
	return 0;
}

//Document related:
static int caculateTheRawWebPageSizeForURL(string size){
	//cout << "	Feature:Document_Raw_Size_of_Web_Page:" << size << " bytes." << endl;
	return 0;
}

//Term related:
static int caculateThePostings(const char* term, int term_len, uint32_t doc_id, uint32_t position, unsigned char context){
	  /*
	  std::cout << "	Feature:Term:";
	  for(int iCounter = 0; iCounter < term_len; iCounter++){
		  std::cout << term[iCounter];
	  }
	  std::cout << ":";
	  std::cout << "(";
	  std::cout << doc_id;
	  std::cout << ", ";
	  std::cout << position;
	  std::cout << ", ";
	  std::cout << (int)context;
	  std::cout << ")";
	  std::cout << std::endl;
	  */
	  return 0;
}

static int caculateTheProbabilityOfBeingSpamForSpecifcWARCTRECID(string WARC_TREC_ID){

	int hamProbability = 90;

	//cout << "	Feature:SpamProbability:" << WARC_TREC_ID << ":" << hamProbability << endl;
	return 0;
}

/*
static int mainForTest(){
	string testURL = "http://www.smartwebby.com/DreamweaverTemplates/templates/business_general_template59.asp";
	cout << "test URL:" << testURL << endl;
	caculateDomainForURL(testURL);
	caculateNumberOfNestingLevelsForURL(testURL);
	caculateLengthForURL(testURL);
	return 0;
}
*/
